home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / vb / winpljz.exe / WINPLAY.TXT < prev    next >
Encoding:
Text File  |  1992-08-09  |  3.1 KB  |  64 lines

  1. WINPLAY.DLL
  2. DLL to provide the PLAY function, found in QB to VB programmers.
  3. by Jonathan Zuck
  4. Published in the Windows Tech Journal, June '92.
  5.  
  6.     Those of your familiar with the PLAY statment, already know how to use it. However, it is missing from VB. WINPLAY.DLL provides this function in a DLL that can be called easily from VB.
  7.  
  8. Function Declaration:
  9. Declare Sub Play Lib "WINPLAY.DLL" (ByVal Song$)
  10.  
  11. For those of you who are not familiar with the syntax of the PLAY statment, here is a table of the things you can use when constructing this string:
  12.  
  13. Table 2 PLAY Commands
  14. Command    Action
  15. A-Gnn    Play that note for that length
  16. #,+    Sharp the immediately previous note.
  17. -    Flat the immediately previous note.
  18. .    Dot the immediately previous note. (3/2 length)
  19.  >    Up one octave
  20.  <     Down one octave
  21. Lnn    Set default length for notes that follow.Default is L4.
  22. MB    Music in background
  23. MF    Music in foreground (default)
  24. ML    Music Legato (full length)
  25. MN    Music Normal (7/8 length)
  26. MS    Music Staccato (3/4 length)
  27. Nnn    Play this numeric note (1-84)
  28. On    Set Octave. (0 - 6).Default is O4, where C is an
  29.     octave above middle C.  Pitches in an octave begin at
  30.     C and work upwards to B.
  31. Pnn    Pause for that duration
  32. Tnnn    Set tempo (32-255). The number of quarter notes in
  33.     one minute.  Default is T120.
  34.  
  35.  
  36. Details:
  37.     This function is not entirely self-contained as it is in QuickPak and VBTOOLS. The reason was to provide complete flexibility, in terms of the buffer used by Windows to hold the notes. When playing notes in the background, a bigger buffer allows more notes to be stored and the function returns to the calling program *much* faster.
  38.     Therefore, you need to call a couple Windows API function to actually make this DLL work. Of course, you could make your own PLAY function in VB which encapsulated all of this.
  39.     Here is a summary of the Windows API functions that you will need to use:
  40.  
  41. Table 1. Sound  Functions in the Windows API
  42. OpenSound    Opens the sound driver for exclusive use
  43. CloseSound    Closes the sound driver, making it available
  44. SetVoiceQueue    Sets the size of the voice queue
  45.  
  46.  
  47. Hopefully the PLAYDEMO.MAK sample will be sufficient to explain the use of each of these function. One caveat that you should keep in mind, however, is that once you have opened the sound queue with OpenSound it is not available to other programs until you issue a closesound. For this reason, it is a good idea to call CloseSound as soon as possible after you are done making a particular sound.
  48.  
  49. Source Code:
  50.     The TPW source for WINPLAY.DLL can be found in Lib 9 of CLMFORUM. Both source and explanation can be found in the June '92 issue of the Windows Tech Journal.
  51.  
  52.  
  53.         For more information or subscriptions to the Windows Tech Journal,
  54. call (800) 234 - 0386 or outside of the US, (503) 747 - 0800. The fax number
  55. is (503) 747 - 0071. Alternatively, you may reach the editor, J.D. Hildebrand
  56.  (until he becomes too popular) here on CIS at id: 76701,32. The journal
  57.  can be reached by mail at:
  58.  
  59.         Windows Tech Journal
  60.         P.O. Box 70167
  61.         Eugene, OR 97401-0110
  62.  
  63. Thanks a lot for your interest! -=- Jonathan
  64.